<template>
  <div class="zhiboxitong">
    <top></top>
    <div class="flex zhiboxitong_content">
      <div class="left">
        <left></left>
      </div>
      <div class="right">
          <div class="zhiboxitong_right">
            <!-- <el-breadcrumb style="font-size: 16px;margin-bottom: 20px;" separator="/">
                <el-breadcrumb-item :to="{ path: '/zhiboxitong/xiaochengxu'}">小程序</el-breadcrumb-item>
                <el-breadcrumb-item>店铺列表</el-breadcrumb-item>
            </el-breadcrumb> -->
              <div style="margin-bottom: 20px;background-color: #DAE7F5;font-size: 14px;color:#333333;display: flex;padding: 11px 12px;align-items:center;border-radius: 10px;width:99%">
              <!-- <div style="background-color:#ADCBFF;color:white;border-radius:50%;width:20px;height:17px;line-height:17px;margin-right:5px;text-align:center">!</div> -->
               <img src="../../static/img/bluelogo.png" style="width:20px;height:20px;margin:0 5px 0 20px;"/>
              <div>
                商城页为多商品罗列在一个页面中，支持分类展示，可用于直播挂载、信息流推广等，如需支付请填写收款配置</div>
            </div>
              <div class="title_flex">
              <div style="margin:0 0 24px 30px;font-weight:bold;font-size:18px;color:#333">小程序页面管理</div>
              <div>
                <el-button v-if='listty=="tt"' @click="toallpage" style="margin-bottom: 20px;margin-right: 20px;border-radius: 10px;">编辑汇总页</el-button>
                <el-button v-if='listty!="wx"' @click="addstore" style="margin-bottom: 20px;margin-right: 20px;background:#F72C50;border:none;border-radius: 10px;color:white">创建起始页</el-button>
              </div>
              
              </div>
            <div class="table_container">
                <el-table
                :header-cell-style="{fontSize: '14px', backgroundColor: 'rgba(246,247,252,0.9)' }"
                :cell-style="{fontSize: '14px', backgroundColor: 'rgba(246,247,252,0.9)' }"
                :data="tableData"
                border
                style="width: 100%">
                <el-table-column
                type="index"
                align="left"
                width="100px"
                label="序列">
                </el-table-column>
                <!-- <el-table-column
                prop="id"
                label="store_id">
                </el-table-column> -->

                <el-table-column
                prop="title"
                align="left"

                label="">
                    <template slot="header">
                        <div>
                          页面名称
                          <el-popover
                            placement="top-start"
                            title=""
                            width="200"
                            trigger="hover"
                            content="该页面名称将显示在用户端">
                            <el-button style="width: 16px;height: 16px;line-height: 16px;padding: 0;font-size: 13px;background-color: #000000A6;border-radius: 50%;color: white;" type="text" slot="reference">?</el-button>
                          </el-popover>
                        </div>
                    </template>
                    <template slot-scope="scope">
                        <span >{{ scope.row.title }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                prop="id"
                align="left"
                label="指定页面分销商户">
                  <template slot="header">
                        <div>
                          指定页面分销商户
                          <el-popover
                            placement="top-start"
                            title=""
                            width="200"
                            trigger="hover"
                            content="从您的分销商中设置分销人，设置后对方直播产生的订单将在H5商城的订单管理中查看到">
                            <el-button style="width: 16px;height: 16px;line-height: 16px;padding: 0;font-size: 13px;background-color: #5794FF;border-radius: 50%;color: white;" type="text" slot="reference">?</el-button>
                          </el-popover>
                        </div>
                    </template>
                    <template slot-scope="scope">
                      <span v-if='scope.row.merchant_id!=0'>{{backname(scope.row.merchant_id)}}<el-button style="margin-left: 10px;color:#005AFF" size="mini" type="text" @click="choosefen(scope.row.id,scope.row.merchant_id)">修改</el-button></span>
                      <el-button v-else size="mini" type="text" @click="choosefen(scope.row.id)" style="color:#005AFF;font-size:14px">选择分销商户</el-button>
                    </template>
                </el-table-column>
                <el-table-column
                prop="id"
                align="left"
                label="起始地址页">
                  <template slot="header">
                        <div>
                          起始地址页
                          <el-popover
                            placement="top-start"
                            title=""
                            width="200"
                            trigger="hover"
                            content="直播间添加小程序时请入该地址">
                            <el-button style="width: 16px;height: 16px;line-height: 16px;padding: 0;font-size: 13px;background-color: #5794FF;border-radius: 50%;color: white;" type="text" slot="reference">?</el-button>
                          </el-popover>
                        </div>
                    </template>
                    <template slot-scope="scope">
                        <el-button size="mini" type="text" @click="copylink(scope.row.app_number)" style="color:#005AFF;font-size:14px">复制链接</el-button>
                    </template>
                </el-table-column>
                <el-table-column scoped-slot align="left" >
                <!-- 在售商品中已下架的商品不会显示在用户端的销售页中 -->
                <template slot="header">
                  <div >
                    自动过滤已下架商品
                    <el-popover
                      placement="top-start"
                      title=""
                      width="200"
                      trigger="hover"
                      content="在售商品中已下架的商品不会显示在用户端的销售页中">
                      <el-button style="width: 16px;height: 16px;line-height: 16px;padding: 0;font-size: 13px;background-color: #5794FF;border-radius: 50%;color: white;" type="text" slot="reference">?</el-button>
                    </el-popover>
                  </div>
                </template>
                <template slot-scope="scope">
                  <el-switch v-model="scope.row.show_down_page" active-color="rgb(8, 201, 160)" inactive-color="rgb(220, 220, 220)" :active-value='0':inactive-value='1' @change="xianshi(scope.row)"></el-switch>
                </template>

              </el-table-column>
                <el-table-column label="操作" width="750px" align="left">
                    <template slot-scope="scope">
                        <el-button type="text" size="mini" plain round
                            @click="setpage(scope.row.type,scope.row.id)" style="color:#005AFF;border:none;font-size:14px;margin-left:-12px">设置页面</el-button>
                        <el-button type="text" size="mini" v-if="scope.row.id != null" plain round
                            @click="setseller(scope.row.id)" style="color:#005AFF;border:none;font-size:14px">管理商品</el-button>

                            <el-button type="text" size="mini" plain round @click="qingkong(scope.row)" style="color:#005AFF;border:none;font-size:14px">清空商品</el-button>

                        <el-button v-if="listty!='wx'" type="text" size="mini" plain round
                            @click="fuzhishangpin(scope.row.id)" style="color:#005AFF;border:none;font-size:14px">从其他页面同步商品</el-button>
                            <el-button  type="text" size="mini"  plain round
                            @click="getdetaillist(scope.row.id)" style="color:#005AFF;border:none;font-size:14px">商品详情链接</el-button>
                            <el-button  type="text" size="mini"  plain round 
                            @click="downxd(scope.row.id)" style="color:#005AFF;border:none;font-size:14px">下载下单记录</el-button>
                    </template>
                </el-table-column>
            </el-table>
            </div>

          </div>
          <div v-if='listty=="tt"&&!this.isgx' class="zhiboxitong_right" style="margin-top: 20px;">
            <div style="color: #647076;margin-bottom: 18px;">管理发布</div>
            <div class="t_xcx_title">线上版本
              <span v-if="xcxbbinfo.current.version==''"></span>
              <span v-else="xcxbbinfo.current.version">：{{ xcxbbinfo.current.version }}</span>
            </div>
            <div v-if="xcxbbinfo.current.version==''" class="t_type_font no_bb" >
              <div style="color: #6B6B6B;text-align: center;width: 100%;">暂无线上版本请发布</div>
            </div>
            <div v-else style="display: flex;justify-content: space-between;align-items: center;">
              <div>

                <div class="t_type_font">
                  <div style="color: #6B6B6B;">提交时间：{{ changetime(xcxbbinfo.current.ctime) }}</div>
                </div>
                <div class="t_type_font" style="margin-top: 20px;margin-bottom: 20px;">
                  <div style="color: #6B6B6B;">备注说明：{{ xcxbbinfo.current.summary }}</div>
                </div>
                <el-button :disabled="!xcxbbinfo.current.rollback.can_rollback" size="small" @click="bbback" type="danger">版本回退{{ xcxbbinfo.current.rollback.last_version }}</el-button>
              </div>
              <div>
                <div>
                  <el-popover
                    placement="left"
                    width="200"
                    trigger="hover">
                    <img style="width: 200px ;" :src="`${this.apis}/api/mini/microapp/app/qrcode?app_id=${this.xcx_fws_id}&mini_id=${this.xcx_id}&version=current`" alt="">
                    <div slot="reference">
                      <img style="width: 70px;
                      height: 70px;cursor: pointer;" :src="`${this.apis}/api/mini/microapp/app/qrcode?app_id=${this.xcx_fws_id}&mini_id=${this.xcx_id}&version=current`" alt="">
                    </div>
                  </el-popover>
                  <div style="font-size: 12px;text-align: center;margin-top: 8px;">预览小程序</div>
                </div>
              </div>
            </div>
            <div style="margin-top: 30px;margin-bottom: 40px;background-color: #e4e4e4;height: 1px;" ></div>
            <div class="t_xcx_title">审核版本
              <span v-if="xcxbbinfo.audit.version==''"></span>
              <span v-else="xcxbbinfo.audit.version">：{{ xcxbbinfo.audit.version }}</span>
            </div>
            <div v-if="xcxbbinfo.audit.version==''" class="t_type_font no_bb" >
              <div style="color: #6B6B6B;text-align: center;width: 100%;">暂无审核中的版本</div>
            </div>
            <div v-else style="display: flex;justify-content: space-between;align-items: center;">
              <div>
                <div class="t_type_font">
                  <div style="color: #6B6B6B;">提交时间：{{ changetime(xcxbbinfo.audit.ctime) }}</div>
                </div>
                <div class="t_type_font" style="margin-top: 20px;margin-bottom: 20px;">
                  <div style="color: #6B6B6B;">备注说明：{{ xcxbbinfo.audit.summary }}</div>
                </div>
                <div class="t_type_font" style="margin-top: 20px;margin-bottom: 20px;">
                  <div style="color: #6B6B6B;">审核状态：
                    <span v-if="xcxbbinfo.audit.status==0">审核中</span>
                    <span v-if="xcxbbinfo.audit.status==1">通过</span>
                    <span v-if="xcxbbinfo.audit.status==2">不通过</span>
                    <span v-if="xcxbbinfo.audit.status==3">撤回审核</span>
                  </div>
                </div>
                <div v-if="xcxbbinfo.audit.status==2" >
                  <div class="t_error_res">审核失败：{{ xcxbbinfo.audit.reason }}</div>
                  <div class="t_type_font">
                    <div style="color: #6B6B6B;">请修改后在待更新版本中再次点击“提交到审核”</div>
                  </div>
                </div>
                <el-button  size="small" v-if="xcxbbinfo.audit.status==0" @click="restsh" type="danger">撤销审核</el-button>
                <el-button :disabled="xcxbbinfo.current.version==xcxbbinfo.audit.version" @click="fpxcx" v-if="xcxbbinfo.audit.status==1&&xcxbbinfo.audit.has_publish==0&&!xcxbbinfo.audit.is_illegal_version" size="small" type="danger">发布小程序</el-button>
              </div>
              <div>
                <div>
                  <el-popover
                    placement="left"
                    width="200"
                    trigger="hover">
                    <img style="width: 200px;" :src="`${this.apis}/api/mini/microapp/app/qrcode?app_id=${this.xcx_fws_id}&mini_id=${this.xcx_id}&version=audit`" alt="">
                    <div slot="reference">
                      <img style="width: 70px;
                      height: 70px;cursor: pointer;" :src="`${this.apis}/api/mini/microapp/app/qrcode?app_id=${this.xcx_fws_id}&mini_id=${this.xcx_id}&version=audit`" alt="">
                    </div>
                  </el-popover>
                  <div style="font-size: 12px;text-align: center;margin-top: 8px;">预览小程序</div>
                </div>
              </div>
            </div>
            <div style="margin-top: 30px;margin-bottom: 40px;background-color: #e4e4e4;height: 1px;" ></div>
            <div class="t_xcx_title">待更新版本
              <!-- <span v-if="xcxbbinfo.latest==null"></span> -->
              <span >：{{ template_info.user_version }}</span>
            </div>
            <!-- <div v-if="xcxbbinfo.latest==null" class="t_type_font no_bb" >
              <div style="color: #6B6B6B;text-align: center;width: 100%;">暂无待更新版本</div>
            </div> -->
            <div style="display: flex;justify-content: space-between;align-items: center;">
              <div>

                <div class="t_type_font">
                  <div style="color: #6B6B6B;">提交时间：{{ template_info.updated_at }}</div>
                </div>
                <div class="t_type_font" style="margin-top: 20px;margin-bottom: 20px;">
                  <div style="color: #6B6B6B;">备注说明：{{ template_info.user_desc }}</div>
                </div>
                <el-button :disabled="!iscanuse" size="small" @click="upsh" type="danger">提交审核</el-button>
              </div>
              <!-- <div>
                <div>
                  <el-popover
                    placement="left"
                    width="200"
                    trigger="hover">
                    <img style="width: 200px;
                  height: 200px;" :src="`${this.apis}/api/mini/microapp/app/qrcode?app_id=${this.xcx_fws_id}&mini_id=${this.xcx_id}&version=latest`" alt="">
                    <div slot="reference">
                      <img style="width: 70px;
                      height: 70px;cursor: pointer;" :src="`${this.apis}/api/mini/microapp/app/qrcode?app_id=${this.xcx_fws_id}&mini_id=${this.xcx_id}&version=latest`" alt="">
                    </div>
                  </el-popover>
                  <div style="font-size: 12px;text-align: center;margin-top: 8px;">预览小程序</div>
                </div>
              </div> -->
            </div>
            <div style="margin-bottom: 20px;background-color: #DAE7F5;font-size: 14px;color:#647076;display: flex;padding: 11px 12px;align-items:center;margin-top: 15px;">
              <!-- <div style="background-color:#ADCBFF;color:white;border-radius:50%;width:20px;height:17px;line-height:17px;margin-right:5px;text-align:center">!</div> -->
              <div>发布流程：请先完整设置页面1的所有信息后点击上方的：“提交审核”按钮，审核通过后请点击“发布上线“，如果状态为发布失败请按照失败原因修改后再次点击发布</div>
            </div>

          </div>

</div>
</div>
      <el-dialog title="选择要同步的页面" :visible.sync="log" :close-on-click-modal="false" width="400px">
        <div class="flex">
          <el-select v-model="fuzhiall.old_id" placeholder="选择要同步的页面">
           <el-option v-for="item in tableData2" :key="item.id" :label="item.title" :value="item.id"></el-option>
          </el-select>
        </div>
        <div style="margin: 20px 0; color: #666;">注：同步后本商品页的商品将被追加</div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="log = false" style="border-radius: 10px;">取消</el-button>
          <el-button type="primary" @click="tongbugo" :disabled="tongbugoing" style="border-radius: 10px;background:#005AFF">确认同步</el-button>
        </span>
      </el-dialog>

      <!-- 新增页面弹窗 -->
      <el-dialog
        title="新增页面"
        :visible.sync="addshow"
        width="500px">
        <el-input v-model="addname" placeholder="请输入页面名称"></el-input>
        <div style="text-align: center;margin-top: 20px;">
          <el-button type="primary" @click="addpagebtn" style="border-radius: 10px;background:#005AFF">新增</el-button>
        </div>
      </el-dialog>
      <!-- 选择分销弹窗 -->
      <el-dialog
        title="选择分销商户"
        :visible.sync="chooseshow"
        width="500px">
        <el-select style="width: 100%;" filterable v-model="fenshop" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
        <div style="text-align: center;margin-top: 20px;">
          <el-button type="primary" @click="addfenbtn" style="border-radius: 10px;background:#005AFF">确定</el-button>
        </div>
      </el-dialog>
      <!-- 详情 -->
      <el-dialog
        title="商品详情地址"
        :visible.sync="isshowpage"
        width="500px">
        <el-select style="width: 100%;" v-model="nowshop" placeholder="请选择商品">
          <el-option
            v-for="item in showlist"
            :key="item.sale_name"
            :label="item.sale_name"
            :value="item.id">
          </el-option>
        </el-select>
        <div v-if="nowshop">
          <div style="margin-top: 20px;margin-bottom: 10px;">
            链接：
          </div>
          <div>
            pages/detail/detail
          </div>
          <div style="margin-top: 20px;margin-bottom: 10px;">
            参数：
          </div>
          <div>
           id={{ this.nowshop }}
          </div>
        </div>
      </el-dialog>
  </div>
</template>

<script>
  import QRCode from 'qrcodejs2'
  import axios from "axios";
  import top from "./components/top.vue";
  import left from "./components/left.vue";
  import chuantu from "../components/chuantu.vue";
  export default {
    components: {
      top,
      left,
      chuantu
    },
    name: "zhiboxitong",
    data() {
      return {
          tableData: [],
          fuzhiall:{
            id:"",
            old_id:""
          },
          log:false,
          tableData2:[],
          tongbugoing:false,
          addshow:false,
          addname:'',
          chooseshow:false,
          fenshop:'',
          options: [{id:0,name:'无分销商'}],
          nowid:'',
          addclickonce:0,
          listty:'tt',
          isgx:false,
          xcxbbinfo:{
            audit:{
              version:'',
              ctime:'',
              summary:'',
              status:'',
              reason:'',
              has_publish:'',
              is_illegal_version:''
            },
            current:{
              version:'',
              ctime:'',
              summary:'',
              rollback:{
                can_rollback:''
              },
            },
            gray:{

            },
            latest:{

            }
          },
          xcx_id:'',
          xcx_fws_id:'',
          template_id:'',
          template_info:'',
          iscanuse:true,
          isshowpage:false,
          showlist:[],
          nowshop:'',
          shopid:"",
      }
    },
    beforeCreate() {

    },
    created() {
      this.listty = this.$route.query.app_id.slice(0, 2)
      if(this.$route.query.xcxtype=='gx'){
        this.isgx = true
      }else{
        this.isgx = false
      }
      console.log(this.$route.query.app_id.slice(0, 2))
      axios.get(`${this.apis}/api/account/shop/info`)
      	.then(response => {
          if (response.data.msg.code == 0) {
            this.shopid = response.data.data.shop_id
          
          }else{
            this.$message.error(response.data.msg.info);
          }
        })
    },
    mounted() {
      this.getlist()
      //获取分销列表
      this.getfenlist()

      if(this.listty=='tt'&&!this.isgx){
        //获取小程序版本信息
        this.getxcxinfo()
      }


    },
    methods: {
      qingkong:function(item){

        this.$confirm('确定要清空吗', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post(`${this.apis}/api/tab/pages/delete`,{ tab:item.id})
            .then(response => {
              if(response.data.msg.code == 0){
                this.getlist()
                this.$message.success('已清空');
              }else{
                this.$message.error(response.data.msg.info);
              }
            });
        })

      },
      //时间戳转年月日时分秒
      changetime(timestamp){
        let time = new Date(timestamp*1000)
      　　let year = time.getFullYear()
      　　const month = (time.getMonth() + 1).toString().padStart(2, '0')
      　　const date = (time.getDate()).toString().padStart(2, '0')
      　　const hours = (time.getHours()).toString().padStart(2, '0')
      　　const minute = (time.getMinutes()).toString().padStart(2, '0')
      　　const second = (time.getSeconds()).toString().padStart(2, '0')

      　　return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
      },
      //获取最新模板
      getnewmodel(xcx_fws_id){
        return new Promise((resolve, reject) => {
          //获取模板列表
          axios.get(`${this.apis}/api/mini/template/list`, {
            params: {
              app_id:xcx_fws_id,
            }
          })
          .then(response => {
            if (response.data.msg.code == 0) {



              console.log('获取模板列表')
              console.log(response.data.data)
              if(response.data.data){
                this.template_info = response.data.data
                this.template_id = response.data.data.template_id

              }
              resolve('获取最新模板成功')

            } else {
              this.$message.error(response.data.msg.info);
            }
          });
        })

      },
      //获取小程序版本信息
      xcxstate(xcx_fws_id,xcx_id){
        return new Promise((resolve, reject) => {
          axios.get(`${this.apis}/api/mini/microapp/package/versions`, {
            params: {
              app_id:xcx_fws_id,
              mini_id:xcx_id
            }
          })
          .then(response => {
            if (response.data.msg.code == 0) {

              console.log('获取小程序版本信息')
              console.log(response.data.data.data.audit)
              this.xcxbbinfo = response.data.data.data
              if(this.xcxbbinfo.audit==null){
                this.xcxbbinfo.audit = {
                  version:'',
                  ctime:'',
                  summary:'',
                  status:'',
                  reason:'',
                  has_publish:'',
                  is_illegal_version:''
                }
              }
              if(this.xcxbbinfo.current==null){
                this.xcxbbinfo.current={
                  version:'',
                  ctime:'',
                  summary:'',
                  rollback:{
                    can_rollback:''
                  },
                }
              }

              resolve('获取小程序版本信息成功')
            } else {
              this.$message.error(response.data.msg.info);
            }
          });
        })

      },
      //小程序信息
      getxcxinfo(){
        //获取mini_id和服务商id
        axios.get(`${this.apis}/api/mini/app/info`, {
            params: {
              app_id:this.$route.query.app_id,
            }
          })
          .then(response => {
            if (response.data.msg.code == 0) {
              console.log('获取mini_id和服务商id')
              console.log(response.data.data)

              this.xcx_id = response.data.data.id
              this.xcx_fws_id = response.data.data.authorizer_appid



              //获取小程序版本信息
              // this.xcxstate(this.xcx_fws_id,this.xcx_id)
              //获取最新模板
              // this.getnewmodel(this.xcx_fws_id)
              Promise.all([ this.xcxstate(this.xcx_fws_id,this.xcx_id),this.getnewmodel(this.xcx_fws_id)]).then((data)=>{
                  // console.log('全部执行完：', data)
                  if(this.xcxbbinfo.current.version!=''){
                    if(this.xcxbbinfo.current.version==this.template_info.user_version){
                       //线上版本号和测试版本号相同不可以使用提交审核
                    this.iscanuse=false
                    }

                  }
                  if(this.xcxbbinfo.current.version!=''&&this.xcxbbinfo.audit.version!=''){
                    if((this.xcxbbinfo.audit.status==1)&&((this.xcxbbinfo.audit.version==this.template_info.user_version)&&this.xcxbbinfo.current.rollback.can_rollback)){
                      //审核通过且审核版本号和测试版本号相同，且没有回退版本，不可提交审核
                      this.iscanuse=false
                    }
                  }

                  if(this.xcxbbinfo.audit.version!=''){
                    if(this.xcxbbinfo.audit.status==0){
                      //审核中的时候不能提审
                      this.iscanuse=false
                    }
                  }



              }, function (e) {
                  console.log('promise.all有异常：', e)
              })


            } else {
              this.$message.error(response.data.msg.info);
            }
        });

      },
      //提交审核
      upsh(){
        //提交代码
        axios.post(`${this.apis}/api/mini/microapp/package/upload`,{
              template_id:this.template_id,
              mini_id:this.xcx_id,
              app_id:this.xcx_fws_id
            })
              .then(response => {
                  if (response.data.msg.code == 0) {
                    this.$message({
                      message: '提交成功',
                      type: 'success'
                    });
                    //获取小程序版本信息
                    this.getxcxinfo()
                  }else{
                    this.$message.error(response.data.msg.info);
                  }
            })

      },
      //撤销审核
      restsh(){
        axios.post(`${this.apis}/api/mini/microapp/package/revoke-audit`,{
              mini_id:this.xcx_id,
              app_id:this.xcx_fws_id
            })
              .then(response => {
                  if (response.data.msg.code == 0) {
                    this.$message({
                      message: '撤回成功',
                      type: 'success'
                    });
                    //获取小程序版本信息
                    this.getxcxinfo()
                  }else{
                    this.$message.error(response.data.msg.info);
                  }
            })
      },
      //发布小程序
      fpxcx(){
        axios.post(`${this.apis}/api/mini/microapp/package/release`, {
              app_id:this.xcx_fws_id,
              mini_id:this.xcx_id,
            })
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message({
                      message: '发布成功',
                      type: 'success'
                    });
                    //获取小程序版本信息
                    this.getxcxinfo()
            } else {
              this.$message.error(response.data.msg.info);
            }
        });
      },
      //版本回退
      bbback(){
        axios.post(`${this.apis}/api/mini/microapp/package/rollback`, {
              app_id:this.xcx_fws_id,
              mini_id:this.xcx_id,
            })
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message({
                      message: '回退成功',
                      type: 'success'
                    });
                    //获取小程序版本信息
                    this.getxcxinfo()
            } else {
              this.$message.error(response.data.msg.info);
            }
        });
      },
      //获取二维码
      // getewm(version){
      //   axios.get(`${this.apis}/api/mini/microapp/app/qrcode`, {
      //           params: {
      //             app_id:this.xcx_fws_id,
      //             mini_id:this.xcx_id,
      //             version:version
      //           }
      //         })
      //         .then(response => {
      //           console.log('获取二维码===')
      //           console.log(response)

      //           return response.data
      //         });
      // },
      fuzhishangpin:function(id){
        this.log = true
        this.fuzhiall.id = id
      },
      tongbugo:function(){
        this.tongbugoing = true
        axios.post(`${this.apis}/api/store/pages/copy`,this.fuzhiall)
          .then(response => {
              if (response.data.msg.code == 0) {
                 this.$message.success('复制成功');
                 this.log = false
                 setTimeout(()=>{
                   this.tongbugoing = false
                 },500)
              }else{
                this.$message.error(response.data.msg.info);
                this.tongbugoing = false
              }
        })
      },
      //获取分销列表
      getfenlist(){
        axios.get(`${this.apis}/api/merchants`)
          .then(response => {
              if (response.data.msg.code == 0) {
                  console.log(response.data.data)
                  if(response.data.data){
                    for(var x=0;x<response.data.data.length;x++){
                      this.options.push(response.data.data[x])
                    }
                  }


              } else {
                  this.$message.error(response.data.msg.info);
              }
          });
      },
      //翻译
      backname(id){
        for(var x = 0;x<this.options.length;x++){
          if(this.options[x].id==id){
            return this.options[x].name
          }
        }
      },
      getlist: function() {
        axios.get(`${this.apis}/api/store/list?page=1&page_size=100&type=5&app_id=${this.$route.query.app_id}`)
          .then(response => {
              if (response.data.msg.code == 0) {
                  console.log(response.data.data.data)
                  if(this.listty=="wx"){
                    var arr = []
                    arr.push(response.data.data.data[0])
                    this.tableData = arr
                  }else{
                     this.tableData = response.data.data.data
                  }
              } else {
                  this.$message.error(response.data.msg.info);
              }
          });

        axios.get(`${this.apis}/api/store/list?page=1&page_size=100&type=5&app_id=${this.$route.query.app_id}`)
          .then(response => {
              if (response.data.msg.code == 0) {
                  this.tableData2 = response.data.data.data
              } else {
                  this.$message.error(response.data.msg.info);
              }
          });
      },
      //复制
      copylink(index){
          if(index==1){
              var link = 'pages/index/index'
          }else{
              var num = index
              var link = 'pages/index'+num+'/index'
          }

          this.copy(link)

          console.log(link)
      },
      //跳转到店铺列表
      setpage(type,id){
          this.$router.push({path: '/zhiboxitong/xiaochengxu/xiaochengxu_fabu',query: {type:type,id:id,app_id:this.$route.query.app_id,xcxtype:this.$route.query.xcxtype}});
      },
      //跳转到管理商品
      setseller(id){
          this.$router.push({path: '/zhiboxitong/xiaochengxu/xiaochengxu_shangpin',query: {id:id,app_id:this.$route.query.app_id,xcxtype:this.$route.query.xcxtype}});
      },
      //新增页面
      addstore(){
        this.addname = ''
        this.addshow = true
      },
      //提交新增页面
      addpagebtn(){
        if(this.addclickonce==0){
          this.addclickonce=1
          axios.post(`${this.apis}/api/store/make2`,{
          app_id:this.$route.query.app_id,
          type:5,
          title:this.addname,

        })
          .then(response => {
              if (response.data.msg.code == 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success'
                });
                this.addshow = false
                this.getlist()
                setTimeout(()=>{
                  this.addclickonce=0
                },2000)

              } else {
                  this.$message.error(response.data.msg.info);
                  this.addclickonce=0
              }
          });
        }

      },
      //选择分销商户
      choosefen(id,nowpeo){
        console.log(id)
        this.nowid = id
        if(nowpeo){
          this.fenshop = nowpeo
        }else{
          this.fenshop = ''
        }
        this.chooseshow = true

      },
      //提交分销人
      addfenbtn(){
        axios.post(`${this.apis}/api/store/merchant`,{
          id:this.nowid,
          merchnat_id:this.fenshop
        })
          .then(response => {
              if (response.data.msg.code == 0) {
                this.chooseshow = false
                this.getlist()
                this.$message({
                  message: '操作成功',
                  type: 'success'
                });
              } else {
                  this.$message.error(response.data.msg.info);
              }
          });

      },
      xianshi:function(item){

        if(item.show_down_page == 0){
          var name = "确定过滤敢探号下架的商品吗？"
        }
        if(item.show_down_page == 1){

          var name = "确定不过滤敢探号下架的商品吗？"
        }
        this.$confirm(name, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post(`${this.apis}/api/store/show/down`,{id:item.id,show_down_page:item.show_down_page})
            .then(response => {
              if(response.data.msg.code == 0){
                this.getlist()
                this.$message.success('已修改成功');
              }else{
                this.$message.error(response.data.msg.info);
              }
            });
        }).catch(() => {
          this.getlist()
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      //获取商品列表
      getdetaillist(id){
          // this.$router.push({path: '/zhiboxitong/xiaochengxu/xiaochengxu_shangpin',query: {id:id,app_id:this.$route.query.app_id,xcxtype:this.$route.query.xcxtype}});

          axios.get(`${this.apis}/api/page/list`,{params:
          {
            page:1,
            page_size:20000,
            tab:id,
            on_sale:0
          }})
          .then(response => {
            if(response.data.msg.code == 0){
              console.log('商品列表')
              console.log(response.data.data.data)
              this.isshowpage = true
              this.showlist = response.data.data.data
              this.nowshop = ''
            }else{
              this.$message.error(response.data.msg.info);
            }
          });
      },
      downxd:function(id){

        axios.post(`${this.apis}/api/store/export/store/web/form`,{id:id})
          .then(response => {
            if(response.data.msg.code == 0){
              console.log(location.origin + '/' + response.data.data.file)
              location.href = location.origin + '/' + response.data.data.file

            }else{
              this.$message.error(response.data.msg.info);
            }
          });
        },
        toallpage(){
          this.$router.push({path:'/zhiboxitong/xiaochengxu/xcxallpage',query:{
            app_id:this.$route.query.app_id,
            xcxtype:this.$route.query.xcxtype,
          }})
        }
    }
  }
</script>
<style scoped>
  .el-alert--info.is-light{
    background-color: #E4EEFF;
  }
  .t_type_font{
    font-size: 14px;
    display: flex;
  }
  .t_error_res{
    font-size: 14px;
    color: #FF3131;
    margin-top: 15px;
    margin-bottom: 15px;
  }
  .t_xcx_title{
    font-size: 18px;
    color: #6C6C6C;
    font-weight: bold;
    margin-bottom: 20px;
}
.no_bb{
  margin-top: 20px;
  margin-bottom: 20px;
  line-height: 100px;

}
</style>
<style scoped lang="less">
  .zhiboxitong {
    // background: #f2f2f2;
    min-height: 100vh;
    /deep/ .el-button--danger.is-plain{ background: #fff;}
    /deep/ .el-button--danger.is-plain:focus, .el-button--danger.is-plain:hover{
      background: #fff; color: #F56C6C;
    }
    * {
      box-sizing: border-box;
    }
    .z{width: 120px;text-align: right;padding-right: 20px; font-size: 14px;}
    .r{}
    .zhiboxitong_content {
      height: calc(100vh - 70px);

      .left {
        width: 210px;
        background: #FAFAFE;
        height: 100%;
      }

      .right {
        width: calc(100vw - 220px);
        height: 100vh;

        // padding: 10px;
        // height: calc(100vh - 70px);
        overflow: auto;

        .zhiboxitong_right {


          
          border-radius: 5px;
          padding: 20px 0 0 20px;
        }

        .zhiboxitong_table {
          margin-top: 30px;
          background: #F8F9FD;
        }

        .xiaochengxuli {
          background: #f9f9f9;
          margin: 10px;
          padding: 20px;
          width: 420px;
          position: relative;

          img {
            width: 100px;
            height: 100px;
          }
        }
      }
    }

    .flex {
      display: flex;
      flex-wrap: wrap;
    }

    .flexb {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
    }

    .flexc {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
    }

    .flexbc {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
    }

    .flexcc {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
    }
    .title_flex{
      display: flex;
      justify-content: space-between;
    }
      /deep/ .el-dialog{
    border-radius:20px;
  }
  
  /deep/ .el-input__inner {
    border-radius:10px;
  background: #F3F5F8;
  // border: none !important;
  box-shadow: none !important;
}
/deep/ .el-dialog__title {
  font-size: 20px;
  font-weight: bold; /* 修改标题字体大小 */
}
/deep/ .el-table{
  background-color: #F8F9FD;
}

// 划过改变table表格背景颜色
/deep/ .el-table__body tr:hover td {
  background-color: white !important;
}
/deep/ .el-table__body tr td:first-child {
  border-radius: 20px 0 0 20px;
   padding-left: 10px;
  box-sizing: border-box;
}
/deep/ .el-table__body tr td:last-child {
  border-radius: 0 20px 20px 0;
}
// 划过改变table表格背景颜色
/deep/ .el-table__body tr:hover > td {
  background-color: white !important;
}
//去掉每行的下边框
  /deep/ .el-table td.el-table__cell,/deep/ .el-table th.el-table__cell.is-leaf {
    border-bottom: none;
    border-right: none;
  } 
 
// 去掉表格单元格边框
.customer-table th{
    border:none;
  }
.customer-table td,.customer-table th.is-leaf {
  border:none;
}
// 表格最外边框
.el-table--border, .el-table--group{
  border: none;
}
// 头部边框
.customer-table thead tr th.is-leaf{
  border: 1px solid #EBEEF5;
  border-right: none;
}
.customer-table thead tr th:nth-last-of-type(2){
  border-right: 1px solid #EBEEF5;
  
}
// 表格最外层边框-底部边框
.el-table--border::after, .el-table--group::after{
  width: 0;
}
/deep/ .el-table__body td {
  height: 72px;
}
.customer-table::before{
  width: 0;
}
.customer-table .el-table__fixed-right::before,.el-table__fixed::before{
  width: 0;
}
// 表格有滚动时表格头边框
.el-table--border th.gutter:last-of-type {
    border: 1px solid #EBEEF5;  
    border-left: none;
}
// 去除边框线
/deep/ .el-table::before {
    height: 0;
}
.table_container{
  width: 100%;
  height: 100%;
  padding: 20px;
  background: rgba(246,247,252,0.9);
   border-top-left-radius: 30px;

}
  }
</style>
